import React from 'react';
import AxModal, { AxGridTwoModal, AxGridThreeModal } from '@/components/AxForm/AxModal';

/** 修改表单 */
export function AxUpdateForm(props) {
  const { handleUpdate, values = {}, ...rest } = props;

  const handleCreate = fieldsValue => {
    const { id } = values;
    if (handleUpdate) {
      return handleUpdate({
        id,
        ...fieldsValue,
      });
    }
  };

  return <AxModal  width={undefined} handleCreate={handleCreate} {...rest} />;
}

/** 两列布局添加表单（24删格布局）
 * @param wholerow 整行所占列数two
 */
export function AxUpdateGridTwoForm(props) {
  const { handleUpdate, values, ...rest } = props;

  const handleCreate = fieldsValue => {
    const { id } = values;
    if (handleUpdate) {
      return handleUpdate({
        id,
        ...fieldsValue,
      });
    }
  };

  return <AxGridTwoModal handleCreate={handleCreate} {...rest} />;
}

/** 三列布局添加表单（24删格布局）
 * @param wholerow 整行所占列数three
 *  */
export function AxUpdateGridThreeForm(props) {
  const { handleUpdate, values, ...rest } = props;

  const handleCreate = fieldsValue => {
    const { id } = values;
    return handleUpdate({
      id,
      ...fieldsValue,
    });
  };

  return <AxGridThreeModal handleCreate={handleCreate} {...rest} />;
}
